

/// 文件类型
/// default_extension_map.dart
enum FileType {
  video,
  image,
  text,
  pdf,
  ppt,
  docx,
  unknown;

  static  final _videoType = {"avi", "flv", "mp4",};
  static  final _imageType = {"png", "svg", "jpg", "jpeg", "gif"};
  static  final _textType = {"txt", "js", "dart"};
  static  final _pdfType = {"pdf"};
  static  final _pptType = {"ppt"};
  static  final _docxType = {"doc", "docx"};

  static FileType parse(String fileSuffix){
    var type = fileSuffix.toLowerCase().trim();
    type = type.substring(type.lastIndexOf(".") + 1 );
    if(_videoType.contains(type)){
      return FileType.video;
    }
    if(_imageType.contains(type)){
      return FileType.image;
    }
    if(_textType.contains(type)){
      return FileType.text;
    }
    if(_pdfType.contains(type)){
      return FileType.pdf;
    }
    if(_pptType.contains(type)){
      return FileType.ppt;
    }
    if(_docxType.contains(type)){
      return FileType.docx;
    }
    return FileType.unknown;
  }

}

